<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="UTF-8">
    <title>网络发布系统</title>
    <link rel="stylesheet" th:href="@{/css/admin/base.css}">
    <link rel="stylesheet" th:href="@{/lib/font-awesome/4.7.0/css/font-awesome.min.css}">
    <link rel="stylesheet" th:href="@{/css/admin/app.css}">
</head>

<body>
<div class="app-login">
    <div class="container">
        <div class="header">
            <h1 class="title">网络发布系统</h1>
        </div>
        <form class="login-form">
            <div class="form-item col">
                <label class="label">账号</label>
                <input type="text" placeholder="请输入账号" name="username" data-name="账号" data-rule="required">
            </div>
            <div class="form-item col">
                <label class="label">密码</label>
                <input type="password" placeholder="请输入密码" name="password" data-name="密码" data-rule="required">
            </div>
            <input hidden="hidden" name="gotoURL" th:value="${gotoURL}">
            <input hidden="hidden" name="setCookieURL" th:value="${setCookieURL}">
            <input hidden="hidden" name="platformTag" th:value="${platformTag}">
            <!--<div class="form-item col">-->
            <!--<label class="label">系统</label>-->
            <!--<input type="password" placeholder="请输入密码" name="password" data-name="密码" data-rule="required">-->
            <!--</div>-->
            <div class="form-msg"></div>
            <div class="form-column z-btn-row">
                <a class="btn-sub z-btn z-btn-l z-primary">登录</a>
                <!--<input class="btn-sub z-btn z-btn-l z-primary" type="submit" value="Submit" value="登录">-->
            </div>
        </form>
    </div>
</div>

<script th:src="@{/lib/jquery.min.js}"></script>
<script th:src="@{/js/form.js}"></script>
<script th:src="@{/js/popup.js}"></script>
<script th:src="@{/js/admin/app.js}"></script>
<script th:src="@{/lib/CryptoJS3/rollups/md5.js}"></script>
<script>
    var form = $(".login-form").form({
        msg: function (msg) {
            popup.tips(msg)
        },
        submit: function () {
            var data = {}

            $.each($(".login-form").serializeArray(), function (index, field) {
                data[field.name] = field.value;
            })

            App.getData({
                url: App.apiUrlHost + '/formLogin',
                data: {
                    username: $('[name=username]').val(),
                    password: CryptoJS.MD5($('[name=password]').val()).toString(),
                    platformTag: $('[name=platformTag]').val(),
                    setCookieURL: $('[name=setCookieURL]').val(),
                    gotoURL: $('[name=gotoURL]').val()
                },
                dataType: 'json',
                type: 'post',
                success: function (result) {

                    if (result.code == 0) {
                        location.href = result.data;
                    } else {
                        popup.tipsTop({type: 'error', msg: result.msg})
                    }
                }
            })
        }
    })
</script>
</body>

</html>